package ltd.service;


import javax.annotation.Resource;

import ltd.dao.GameDao;
import ltd.entity.Game;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.googlecode.genericdao.search.Search;

import java.util.List;

@Service(value="gameService")
@Scope("singleton")
@Transactional(readOnly=true,propagation=Propagation.REQUIRED)
public class GameService {
	
	@Resource 
	private GameDao gameDao;

	@Transactional(readOnly=false, propagation=Propagation.REQUIRED)
	public boolean save(Game game) {
		return this.gameDao.save(game);
	}

	@Transactional(readOnly=false, propagation=Propagation.REQUIRED)
	public boolean[] save(Game[] games) {
		return this.gameDao.save(games);
	}

	@Transactional(readOnly=false, propagation=Propagation.REQUIRED)
	public boolean remove(Game game) {
		return this.gameDao.remove(game);
	}

	@Transactional(readOnly=false, propagation=Propagation.REQUIRED)
	public void remove(Game[] games) {
		this.gameDao.remove(games);
	}

	@Transactional(readOnly=false, propagation=Propagation.REQUIRED)
	public boolean removeById(Integer id) {
		return this.gameDao.removeById(id);
	}

	@Transactional(readOnly=false, propagation=Propagation.REQUIRED)
	public void removeByIds(Integer[] ids) {
		this.gameDao.removeByIds(ids);
	}

	public List<Game> findAll() {
		return this.gameDao.findAll();
	}

	public Game findById(Integer id) {
		return this.gameDao.find(id);
	}

	public Game[] findByIds(Integer[] ids) {
		return this.gameDao.find(ids);
	}

	public int count(Search search) {
		return this.gameDao.count(search);
	}

	public List<Game> search(Search search) {
		return this.gameDao.search(search);
	}
	
	public Game searchOne(Search search) {
		return this.gameDao.searchUnique(search);
	}

	public void flush() {
		this.gameDao.flush();
	}
}
